#include "ad_sechname.h"
#include "ui_ad_sechname.h"
#include"dlcw.h"
#include<QMessageBox>
extern std::string _name;

ad_sechname::ad_sechname(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ad_sechname)
{
    ui->setupUi(this);
    setWindowTitle("查找用户");
}

ad_sechname::~ad_sechname()
{
    delete ui;
}

void ad_sechname::on_okbtn_clicked() //点击确认开始搜索用户
{
    QString ctmname=ui->customname->text().trimmed();
    if(ctmname.size()==0){
        QMessageBox::warning(this,"err","用户名不能为空");
        return;
    }
    std::string zjbl=_name;
    _name=ctmname.toStdString();   
    int testAcc=1;
    Accp p, head;
    head = ff();
    p = head;
    std::string adminname;
    adminname="admin123";
    while (p != NULL)   //遍历链表，寻找当前输入的账户的账号
    {
        if (strcmp(p->name, _name.c_str()) == 0||strcmp(adminname.c_str(),_name.c_str())==0)
        {
            testAcc = 0;
            break;
        }
        p = p->next;
    }
    if (testAcc != 0)        //如果没有重复账号
    {
        QMessageBox::warning(this,"err","账号不存在");
        _name=zjbl;
    }
    else accept();
}
